package com.aistar.service.impl;

import com.aistar.mapper.ReviewMapper;
import com.aistar.pojo.Review;
import com.aistar.pojo.ReviewExample;
import com.aistar.service.ReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReviewServiceImpl implements ReviewService {
    @Autowired
    private ReviewMapper reviewMapper;

    @Override
    public boolean save(Review review) {
        return reviewMapper.insert(review)>0;
    }

    @Override
    public List<Review> getByShopId(Integer shopId) {
          ReviewExample example = new ReviewExample();
        ReviewExample.Criteria criteria = example.createCriteria();
        criteria.andShopIdEqualTo(shopId);

        List<Review> memberList = reviewMapper.selectByExample(example);

        return memberList;
    }

    @Override
    public Review getById(Integer id) {
      return  reviewMapper.selectByPrimaryKey(id);
    }
}
